<?php
/**
 * created by zzy
 * date: 2017/10/20 18:00
 */

namespace App\Eloquent\Ygt;

class Permission extends DbEloquent{

    protected $table    = 'ygt_permission';

    public static function getListByIds( $id_arr ){

        $where              = [ 'id'=>['in',$id_arr] ];
        $result             = self::getList( $where );
        return $result;
    }

    public static function getInfoById( $id ){

        $where              = [ 'id'=>$id ];
        $result             = self::getInfo( $where );
        return $result;
    }
    //根据工序id取对应的权限id
    public static function getIdByProcessId( $process_id ){
        $where          = ['type'=>1, 'type_id'=>$process_id];
        $result         = self::getOneValue( $where, 'id' );
        return $result;
    }
    //取不同权限类型 的 动作类型列表
    public static function getTypeActionList( $type, $is_list=true ){
        //0默认1工序2产品
        switch ($type){
            case 1:
                $lists          = [
                    ['id'=>1,'title'=>'查看'], ['id'=>2,'title'=>'可写'],
                    ['id'=>3,'title'=>'分配'], ['id'=>4,'title'=>'提交'],
                    ['id'=>5,'title'=>'转发'], ['id'=>6,'title'=>'仓库消息'],
                    ['id'=>7,'title'=>'基础字段']
                ];
                break;
            case 2:

                break;
            default:
        }
        if( $is_list ){
            $result             = $lists;
        } else {
            foreach( $lists as $key=>$val ){
                $result[$val['id']] = $val['title'];
            }
        }
        return $result;
    }

}